import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:{},
    login:false,
    avatar: ''
  },
  mutations: {
    SET_USER: (state, user) => {
      state.user = user
    },
    SET_LOGIN: (state, login) => {
      state.login = login
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
  },
  actions: {
    Login({commit},form) {
      commit('SET_USER', form)
      commit('SET_LOGIN', true)
      commit('SET_AVATAR', form.avatar)
    },
    LogOut({commit}) {
      commit('SET_USER',{})
      commit('SET_LOGIN', false)
      commit('SET_AVATAR','')
    }
  },
  modules: {
  }
})
